package com.drojian.demo3;

import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.VideoView;

import com.drojian.demo.R;
import com.drojian.demo2.BaseFragment2;


public class BaseFragment3 extends Fragment implements View.OnClickListener {
    private View view;
    private VideoView video;
    private Button begin,stop,end;

    public static BaseFragment3 newInstance() {
        return new BaseFragment3();
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
         view = inflater.inflate(R.layout.part3_fragment_base3, container, false);
         video = view.findViewById(R.id.video);
         begin = view.findViewById(R.id.begin);
         stop = view.findViewById(R.id.stop);
         end = view.findViewById(R.id.end);
         begin.setOnClickListener(this);
         stop.setOnClickListener(this);
         end.setOnClickListener(this);
         video.setVideoURI(Uri.parse("android.resource://com.drojian.demo/" + R.raw.video));
         return view;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.begin:
                video.start();
                break;
            case R.id.stop:
                video.pause();
                break;
            case R.id.end:
                video.stopPlayback();
                break;
        }
    }


}